package com.example.demo.admin.gecco.crawler.mzt;

import com.example.demo.admin.gecco.entity.CategoryType;
import com.geccocrawler.gecco.pipeline.Pipeline;
import com.geccocrawler.gecco.request.HttpRequest;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NextPagePipeline implements Pipeline<SecondPage> {

    private static String role = "/pic";
    @Override
    public void process(SecondPage bean) {

        List<CategoryType> categoryTypes = bean.getCategoryTypes();
        for (CategoryType categoryType : categoryTypes) {

            if(categoryType.getUrl()!=null && categoryType.getUrl().indexOf(role)>=0){
                HttpRequest sub = bean.getRequest().subRequest(categoryType.getUrl());
                sub.addParameter("tag", ""+categoryType.getId());
                System.out.format("url: {%s}",sub.getUrl());
                //SchedulerContext.into(sub);
            }
        }

        String nextUrl = bean.getLastPageUrl();
        System.out.format("nextUrl: {%s}",nextUrl);

    }
}